home *** CD-ROM | disk | FTP | other *** search
/ Archive Magazine CD 1995 / Archive Magazine CD 1995.iso / discs / prog_disc / volume_1 / issue_11 / renum / number < prev    next >
Encoding:
Text File  |  1995-06-13  |  3.4 KB  |  95 lines

  1.  
  2.     Partial Renumber Routine
  3.     ------------------------
  4.  
  5. The partial renumber routine as supplied works extremely well. I have
  6. employed it with a wide variety of programs with complete success, and
  7. would therefore like to extend my congratulations and appreciation to
  8. the author.
  9.  
  10. I have, however, disvcovered a number of small items which I feel I
  11. should  bring to your attention. Ideally, I would have liked to offer a
  12. revised version of the routine for your opinion, but I have found the
  13. code rather difficult to follow.
  14.  
  15. The routine starts by asking for various input parameters, such as the
  16. start and end line numbers for renumbering. These are not checked. If
  17. return is pressed the line number is defaulted. However, if a start line
  18. number with a greater value than the end line number is entered, the 
  19. routine will still faithfully attempt a renumber...
  20.  
  21.  
  22.  
  23. The routine also permits the user to issue a renumber that would alter
  24. the structure of a program. For example, take a small program such as
  25. the one below:-
  26.  
  27.         10 REM Line 1
  28.         20 REM Line 2
  29.         30 REM Line 3
  30.         40 REM Line 4
  31.  
  32. This may be amended by the routine using input parameters of:-
  33.  
  34.         20,30,100,10,0
  35.  
  36. to read:-
  37.  
  38.         10 REM Line 1
  39.            100 REM Line 2    
  40.            110 REM Line 3
  41.             40 REM Line 4
  42.  
  43. In effect, there is nothing wrong with this. It is just that BBC Basic
  44. is not capable of re-shuffling the program, and that will cause a
  45. problem. There are two possible solutions to this programmer. The first
  46. is to build a chek routine into the renumber utility preventing the
  47. above renumber  from starting. (Could be a rather difficult job - I
  48. don't know). The second is to leave such a problem to the programmer to
  49. resolve.
  50.  
  51. How? Simple. SPOOL the program to disc, then EXEC the generated file
  52. back into memory. This imitates the program being typed in from the 
  53. keyboard, allowing BASIC to sort out where to stick each line in turn.
  54.  
  55. In the above example, this would result in the following:-
  56.  
  57.         10 REM Line 1
  58.         40 REM Line 4
  59.            100 REM Line 2
  60.            110 REM Line 3
  61.  
  62.  
  63. In the time that I have been using the routine, I have found that I very
  64. quickly adopted a standard method of renumbering a program. 
  65.  
  66.   1.  Renumber the routine itself to a block of line numbers that do not
  67.       exist in the program to be amended. (For my own software, I know
  68.       that lines 64000 to 65535 are always unused). It is  best to add
  69.       the procedure to the end of the program you wish to renumber,
  70.       since BBC Basic provides the APPEND statement.
  71.  
  72.   2.  Save this to disc under the name RENUM either as a basic  program
  73.       or as a spooled file.
  74.  
  75.   3.  Either append the PROCRENUM to your program, or create a  spooled
  76.       version and use EXEC to add it to the code of your own program.
  77.  
  78.   4.  Call PROCRENUM to make the required changes. Ensure that they are
  79.       correct with a quick LIST.
  80.  
  81.   5.  Delete the lines of your program that contain the RENUM routines.
  82.       This will leave only the amended program in memory.
  83.  
  84.   6.  Save this back to disc.
  85.  
  86. RENUM and its associated procedures do not declare local variables. For 
  87. that reason I was reluctant to leave it as part of a program and call it
  88. when required, since a clash of variable names may have occured.
  89.  
  90. In reality, the comments I have made are superfluous to the functioning
  91. of the utility. A careful programmer can check his line numbers before
  92. calling the procedure to ensure that the above listed error conditions
  93. are not permitted to occur.
  94.  
  95.